package com.zzyk.main.service.impl;


import com.zzyk.main.mapper.SysOrganizationDao;
import com.zzyk.main.model.pojo.Organization;
import com.zzyk.main.model.vo.OrganizationInfo;
import com.zzyk.main.service.ISysOrganizationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SysOrganizationServiceImpl implements ISysOrganizationService {

    @Autowired
    private SysOrganizationDao organizationDao;

    @Override
    public List<OrganizationInfo> list(Organization organization) {
        return organizationDao.getOrganizationList(organization);
    }

    @Override
    public OrganizationInfo get(int id) {
        return organizationDao.getOrganization(id);
    }

    @Override
    public OrganizationInfo get(String name) {
        return organizationDao.getOrganizationByName(name);
    }

    @Override
    public List<Organization> getList(String[] ids){
        return organizationDao.getOrganizationsByIds(ids);
    }

    @Override
    public int add(Organization organization) {
        return organizationDao.addOrganization(organization);
    }

    @Override
    public int update(Organization organization) {
        return organizationDao.updateOrganization(organization);
    }

    @Override
    public int del(int id) {
        return organizationDao.delOrganization(id);
    }

    @Override
    public List<OrganizationInfo> getAreaById(Integer id) {
        OrganizationInfo organizationInfo = get(id);
        return organizationDao.selectAreaById(organizationInfo.getArea());
    }

    @Override
    public List<Organization> getAllByParam(String[] area, String param) {
        return organizationDao.selectAllByParam(area,param);
    }
}
